import { kgjHttp as http } from '@/services/http';
import type { SortAndLimit, ListResult } from '@/types/api/common';
import type { UserItem, UserListDataDto, LecturerItem, MajorCustomerReqDto, MajorCustomerResultItem, UserUpdateReqDto, SendCodeDto } from '@/types/api/crm-kgj/user';

interface CommonDetailProp {
  id: number;
}
/** 用户管理 - 获取用户列表 */
export const getUserList = (payload: { data: UserListDataDto; params: SortAndLimit }) => {
  return http<ListResult<UserItem>, UserListDataDto, SortAndLimit>({
    url: '/api/user/list',
    method: 'post',
    ...payload
  });
};
/** 获取讲师列表 */
export const getLecturerList = () =>
  http<ListResult<LecturerItem>>({
    url: '/api/user/lec',
    method: 'get'
  });
/** 用户管理 - 更新用户信息  */
export const updateUserDetail = (data: UserUpdateReqDto) =>
  http({
    url: '/api/user/edit',
    method: 'post',
    data
  });
/** 用户管理 - 获取用户日志 */
export const getUserLogs = (params: CommonDetailProp) =>
  http({
    url: '/api/user/log',
    method: 'get',
    params
  });

/** 用户管理 - 赠送兑换码 */
export const giftExchangeCode = (data: SendCodeDto) =>
  http({
    url: '/api/user/sendcode',
    method: 'post',
    data
  });

/** 获取大客户线索列表 */
export const getMajorCustomerList = (payload: { data: MajorCustomerReqDto; params: SortAndLimit }) =>
  http<ListResult<MajorCustomerResultItem>, MajorCustomerReqDto, SortAndLimit>({
    url: '/api/user/leaveinfo/list',
    method: 'post',
    ...payload
  });

/** 删除大客户 */
export const deleteMajorCustomer = (params: CommonDetailProp) =>
  http({
    url: '/api/user/leaveinfo/remove',
    method: 'get',
    params
  });
/** 更新大客户备注信息 */
export const updateCustomerRemark = (data: { id: number; remark: string }) =>
  http({
    url: '/api/user/leaveinfo/remark',
    method: 'post',
    data
  });
